<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>应用管理</title>
<link href="styles/general.css" rel="stylesheet" type="text/css" /><link href="styles/main.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="js/common.js"></script>
     <script type="text/javascript" src="js/sorttable.js"></script>
    <script src="js/utils.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/jquery/uploadify/jquery.min.js"></script>
	

<link rel="stylesheet" type="text/css" href="http://ajax.pupkk.com/dojo/1.7.5/dojo/resources/dojo.css" />
	<link rel="stylesheet" type="text/css" href="http://ajax.pupkk.com/dojo/1.7.5/dijit/themes/tundra/tundra.css" />
	<script src="http://ajax.pupkk.com/dojo/1.7.5/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
    <script type="text/javascript">
		dojo.require("dojo.parser");
		dojo.require("dijit.form.DateTextBox");
		dojo.require("dijit.form.FilteringSelect");
		function appchanneldel(type,id){
			window.location.href="appchannelapk_save.do?type="+type+"&model.id="+id;
		}
		function appchannelapkshow(type,id,msg)
		{
			var appid = dijit.byId("appid").get('value');
			var appversionid = document.getElementById("appversionid").value;
			var channelid = dijit.byId("channelid").get('value');
			var appname = document.getElementById("appname").value;
			var url = "appchannelapk_show.do?type="+type+"&model.id="+id+"&appid="+appid+"&appversionid="+appversionid+"&channelid="+channelid+"&appname="+appname;
			if(msg){
				url+="&msg="+msg;
			}
			window.location.href=url;
			
		}
		function offonline(appstatus,id)
		{
			$.get("appchannelapk_saveoffonline.do?type=offonline&model.id="+id+"&model.appstatus="+appstatus); 
		}
		function onchangeappxml()
		{
			var objSelect = document.getElementById("appversionid");
			 for (var i = 0; i < objSelect.options.length; i++) {        
		            if (objSelect.options[i].value != '-1') {        
		                objSelect.options.remove(i);        
		            }
			 }
			if(dijit.byId("appid").get('value')!="")
			{
				$.ajax({    
				    url:'appchannelapk_changeappxml.do?appid='+dijit.byId("appid").get('value'),    
				    type: 'GET',    
				    dataType: 'xml',    
				    timeout: 1000,    
				    error: function(xml){    
				        alert('Error loading XML document'+xml);    
				    },    
				    success: function(xml){    
				        $(xml).find("appversion").each(function(i){    
				            var id_value=$(this).children("id").text(); 
				            var appname_value=$(this).children("appname").text();
				            if(appname_value!=null && appname_value!="")
				            {
				            	var varItem = new Option(appname_value, id_value);      
				                objSelect.options.add(varItem);     
				            }
				            
				        });   
				    } 
	  	         });
			}
		}
		function handOut(url){
			document.getElementById("msgDiv").innerHTML="";
			var sWidth, sHeight;
		    sWidth  = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth); 
		    sHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); 
		    var bgObj = document.getElementById("bgDiv"); 
		    bgObj.style.position = "absolute";
		    bgObj.style.top = "0";
		    bgObj.style.background = "#817977";
		    bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=40,finishOpacity=60)";
		    bgObj.style.opacity = "0.4";
		    bgObj.style.left = "0";
		    bgObj.style.width = sWidth + "px";
		    bgObj.style.height = sHeight + "px";
		    bgObj.style.zIndex = "10000"; 

		    var msgObj = document.getElementById("msgDiv");
		    msgObj.style.position = "absolute";
		    msgObj.style.left = "40%";
		    msgObj.style.top = "20%";
		    msgObj.style.right = "10%";
		    msgObj.style.marginLeft = "-300px";
		    msgObj.style.marginTop = -75 + document.documentElement.scrollTop + "px";
		    msgObj.style.lineHeight = "25px";
		    msgObj.style.zIndex = "10001";
		    msgObj.style.display="";
		    bgObj.style.display="";
		    $.get(url,function(data){
		    	 document.getElementById("msgDiv").innerHTML=data;
		    });
		}
		function closechannelapp(){
			$("#bgDiv,#msgDiv").hide();
		}
	</script>
</head>

<body>
<h1>
        <span class="action-span"><a href="javascript:void(0);" onclick="appchannelapkshow('insert','-1')">添加渠道包</a></span> 
        
        <span
            class="action-span1"><a href="mainframe.jsp">
                首页</a> </span><span id="search_id" class="action-span1">- 渠道包管理 </span>
    </h1><br />
    <!--搜索 -->
    <div style="display:none;">
    <form name="form1" method="post" action="appchannelapk_list.do" id="form1">
    <div class="form-div">
        <div id="Panel1">
	
            <img height="22" width="26" border="0" alt="SEARCH" src="img/icon_search.gif">
            应用：
            <select id="appid" name="appid" dojoType="dijit.form.FilteringSelect" onchange="onchangeappxml()">
            	<option value="">--选择应用--</option>
            	<s:iterator value="applist">
            			<option <s:if test="appnumber.equals(appid)">selected</s:if> value="<s:property value="appnumber" />"><s:property value="appname" /></option>
            	</s:iterator>
            </select>
            应用版本：<select id="appversionid" name="appversionid">
            	<option value="-1">--选择版本--</option>
            	<s:iterator value="appversionlist">
            			<option <s:if test="id.equals(appversionid)">selected</s:if> value="<s:property value="id" />"><s:property value="appname" /></option>
            	</s:iterator>
            </select>
            
            渠道：
            <select id="channelid" name="channelid" dojoType="dijit.form.FilteringSelect">
            	<option value="-1">--选择渠道--</option>
            	<s:iterator value="channellist">
            		<option <s:if test="id.equals(channelid)">selected</s:if> value="<s:property value="id" />"><s:property value="name" /></option>
            	</s:iterator>
            </select>
            渠道包名称：
        <input name="appname" type="text" id="appname"  value="<s:property value="appname"/>"/>
        <input type="submit" name="ButtonSearch" value=" 搜索 " id="ButtonSearch" class="button" />
</div>
    </div>
    </form></div>
   <!-- start ad menu list -->
    <div class="list-div" id="listDiv">
        <table width="100%" cellspacing="1" cellpadding="2" class="sortable" id="sortable">
            <tbody>
                <tr>
                    <th height="20">序号</th>
				    <!-- <th>应用</th> -->
				    <th>渠道包名称</th>
				    <th>发行版本名称</th>
				    <th>渠道名称</th>
				    <th>状态</th>
				    <th></th>
				    <th></th>
                </tr>
                <s:if test="list.size()>0">
  				<s:iterator value="list" var="l" status="i"> 
  					 <tr>
                            <td style="background-color: rgb(255, 255, 255);"><s:property value="#i.count"/></td>
                            <!-- <td style="background-color: rgb(255, 255, 255);">
                            <s:iterator value="applist">
			            			<s:if test="appnumber.equals(list.get(#i.count-1).appnumber)"> <s:property value="appname"/></s:if>
			            	</s:iterator>
                            </td> -->
                            <td style="background-color: rgb(255, 255, 255);"><s:property value="appname"/></td>
                            <td style="background-color: rgb(255, 255, 255);">
                            <s:iterator value="appversionlist1">
                            	<s:if test="id.equals(appversionid)"><s:property value="appname"/></s:if>
                            </s:iterator>
                            <s:iterator value="apvtlist">
                            		<s:if test="appversionId.equals(#l.appversionid)">(<s:property value="operatorsName" />)</s:if>
                            </s:iterator>
                            </td>
                            <td style="background-color: rgb(255, 255, 255);">
                            	<s:if test="channelid>0">
                            	<s:iterator value="channellist">
                            			<s:if test="id.equals(channelid)"><s:property value="name" /></s:if>
                            	</s:iterator>
                            	</s:if>
                            	<!--<s:else>未知</s:else>-->
                            </td>
						    <td style="background-color: rgb(255, 255, 255);">
						    <select onchange="offonline(this.value,'<s:property value="id"/>');">
						    	<option <s:if test='"0".equals(appstatus)'>selected</s:if> value="0">打包</option>
						    	<option <s:if test='"1".equals(appstatus)'>selected</s:if> value="1">测试</option>
						    	<option <s:if test='"2".equals(appstatus)'>selected</s:if> value="2">商用</option>
						    </select>
						    </td>
						    <td align="left" style="background-color: rgb(255, 255, 255);">
						    	<a href="app_show1.do?type=channelapk&model.appnumber=<s:property value="appnumber"/>&channelapkid=<s:property value="id"/>">物料</a>
						    	&nbsp;<a href="javascript:void(0);" onclick="handOut('appchannelapk_showpack.do?model.id=<s:property value="id"/>');">打包信息</a>
						    </td>
						    <td align="left" style="background-color: rgb(255, 255, 255);">
						     <s:if test="isUpdate.equals('true')">
							     <a href="javascript:void(0);" onclick="appchannelapkshow('update','<s:property value="id"/>')">
							     	<img height="16" width="16" border="0" src="img/icon_edit.gif" alt="编辑"></a>&nbsp;
							     <a href="javascript:void(0);" onclick="if(confirm('警告！！确定要删除吗？')){appchanneldel('del','<s:property value="id"/>')}" >
									<img height="16" width="16" border="0" src="img/icon_trash.gif" alt="删除">
								</a>
							</s:if>
							<s:else>
								<a href=" javascript:void(0);" onclick="appchannelapkshow('update','<s:property value="id"/>')">
									<img height="16" width="16" border="0" src="img/icon_view.gif" alt="查看">
								</a>   
							</s:else>
              <!--<s:if test="appfilename!='null'&&appfilename.length()>0">
                <a href="<%=request.getContextPath() %>/appchannelapk_downApp.do?model.id=<s:property value="id"/>">
                  <img height="16" width="16" border="0" src="img/icon_download.png" alt="下载">
                </a>
              </s:if>		-->			 
							</td>
  					</tr>
  				</s:iterator>
  				</s:if>
  </tbody>
  </table>
  </div>
 <!--Bottom开始-->
    <script language="JavaScript">

if (document.getElementById("listDiv"))
{
  document.getElementById("listDiv").onmouseover = function(e)
  {
    obj = Utils.srcElement(e);

    if (obj)
    {
      if (obj.parentNode.tagName.toLowerCase() == "tr") row = obj.parentNode;
      else if (obj.parentNode.parentNode.tagName.toLowerCase() == "tr") row = obj.parentNode.parentNode;
      else return;

      for (i = 0; i < row.cells.length; i++)
      {
        if (row.cells[i].tagName != "TH") row.cells[i].style.backgroundColor = '#eeeded';
      }
    }

  }

  document.getElementById("listDiv").onmouseout = function(e)
  {
    obj = Utils.srcElement(e);

    if (obj)
    {
      if (obj.parentNode.tagName.toLowerCase() == "tr") row = obj.parentNode;
      else if (obj.parentNode.parentNode.tagName.toLowerCase() == "tr") row = obj.parentNode.parentNode;
      else return;

      for (i = 0; i < row.cells.length; i++)
      {
          if (row.cells[i].tagName != "TH") row.cells[i].style.backgroundColor = '#FFF';
      }
    }
  }

}

    </script>
    
<div id="footer">
<br />
<s:property value="bottom"/></div>
    <!--Bottom结束-->
    <div id="msgDiv" style="display:none;"></div>
<div id="bgDiv" style="display:none;" onclick="closachannelapp();"></div>
</body>
</html>